package org.aphelie.chronicle.ui;

import org.aphelie.chronicle.ArcMessages;
import org.aphelie.chronicle.ui.i18n.ChronicleUIMessages;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.osgi.framework.BundleContext;

/**
 * The activator class controls the plug-in life cycle
 */
public class ChronicleUIPlugin extends ArcUIPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "org.aphelie.chronicle.ui"; //$NON-NLS-1$

	// The shared instance
	private static ChronicleUIPlugin plugin;
	

	
	/**
	 * The constructor
	 */
	public ChronicleUIPlugin() {
	}
	
	/* Messages */
	private static ArcMessages messages = new ChronicleUIMessages();
	
	public static ArcMessages getMessages() {
		return messages;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static ChronicleUIPlugin getDefault() {
		return plugin;
	}
	
	private final static boolean DEBUG = true;
	
	public void setCompositeBackgroundColor(Composite composite) {
		if (DEBUG) {
			Device device = Display.getCurrent();
			int red = (int) (Math.random() * 256);
			int green = (int) (Math.random() * 256);
			int blue = (int) (Math.random() * 256);

			Color color = new Color(device, red, green, blue);
			composite.setBackground(color);
		}
	}

}
